﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Web;

namespace HotelRegistrationSystem.Models
{
    public class HotelViewModel
    {
        public int HotelId { get; set; }

        [Required]
        [StringLength(25, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "Hotel Name")]
        public string Name { get; set; }

        [Display(Name = "Earliest check in")]
        public TimeSpan? EarliestCheckIn { get; set; }

        [Display(Name = "Latest check out")]
        public TimeSpan? LatestCheckOut { get; set; }

        public AddressModel Address { get; set; }

        [Required(ErrorMessage = "Required")]
        [Display(Name = "Hotel phone number")]
        public string PhoneNumber { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$",
            ErrorMessage = "Invalid Email Address")]
        [Display(Name = "Email address")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Required")]
        [Display(Name = "Type of the place")]
        public int HotelTypeId { get; set; }

        [StringLength(4000, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        [Display(Name = "Description")]
        public string HotelDescription { get; set; }

        [RegularExpression("([0-9]+)", ErrorMessage = "Invalid, must be a positive number")]
        public int? Earnest { get; set; }

        [RegularExpression("([0-9]+)", ErrorMessage = "Invalid, must be a positive number")]
        [Display(Name = "Reservation deny period")]
        public int? ReservationDenyPeriod { get; set; }

        [RegularExpression("([0-9]+)", ErrorMessage = "Invalid, must be a positive number")]
        [Display(Name = "Contact period")]
        public int? ContactPeriod { get; set; }

        [Required(ErrorMessage = "Required")]
        [Display(Name = "Verification/ Payment type")]
        public int ReservationTypeId { get; set; }

        [Range(1, 5, ErrorMessage = "Stars must be from 1 to 5")]
        [Required(ErrorMessage = "Stars are required")]
        [Display(Name = "Stars")]
        public byte Stars { get; set; }

        public string PictureName { get; set; }

        [Display(Name = "Upload new hotel picture")]
        public HttpPostedFileBase NewImage { get; set; }
    }

    public class HotelIndexPageModel
    {
        public int HotelId { get; set; }

        public string Name { get; set; }

        public AddressModel Address { get; set; }

        [Display(Name = "Phone")]
        public string PhoneNumber { get; set; }

        public string Email { get; set; }

        public string PictureName { get; set; }

        public int UserId { get; set; }

        public byte Stars { get; set; }

        public int RoomsCount { get; set; }

        public int BedsCount { get; set; }
    }

    public class CreateHotelModel
    {
        [Required]
        [StringLength(25, ErrorMessage = "Length must be between {2} and {1} symbols", MinimumLength = 3)]
        //[RegularExpression(@"^[A-Za-z][A-Za-z0-9]+$", ErrorMessage = "Invalid hotel name")]
        [Display(Name = "Hotel Name")]
        public string HotelName { get; set; }

        [Display(Name = "Earliest check in")]
        public TimeSpan? EarliestCheckIn { get; set; }

        [Display(Name = "Latest check out")]
        public TimeSpan? LatestCheckOut { get; set; }

        [Required(ErrorMessage = "Required")]
        [Display(Name = "Address")]
        public int AddressId { get; set; }

        public int UserId { get; set; }

        [Required]
        [DataType(DataType.PhoneNumber)]
        [Display(Name = "Phone Number")]
        public string PhoneNumber { get; set; }

        [Required]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$",
            ErrorMessage = "Invalid Email Address")]
        [Display(Name = "Email Address")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Required")]
        public int HotelTypeId { get; set; }

        public string Description { get; set; }

        public int? Earnest { get; set; }

        [Display(Name = "Reservation Deny period")]
        public int? ReservationDenyPeriod { get; set; }

        [Display(Name = "Contact period")]
        public int? ContactPeriod { get; set; }

        [Required(ErrorMessage = "Reservation type")]
        public int ReservationTypeId { get; set; }

        [Range(1, 5, ErrorMessage = "Stars must be from 1 to 5")]
        [Required(ErrorMessage = "Stars are required")]
        [Display(Name = "Stars")]
        public byte Stars { get; set; }
    }

    public class HotelSearchModel
    {
        [Display(Name = "Hotel name")]
        public string Name { get; set; }

        [Range(1, Int32.MaxValue, ErrorMessage = "Beds must be positive")]
        [Display(Name = "Minimum rooms")]
        public int? RoomsCountMin { get; set; }

        [Range(1, Int32.MaxValue, ErrorMessage = "Beds must be positive")]
        [Display(Name = "Minimum beds")]
        public int? BedsCountMin { get; set; }

        [Range(1, 5, ErrorMessage = "Stars must be from 1 to 5")]
        [Display(Name = "Minimum stars")]
        public int? StarsMin { get; set; }

        [Range(1, 5, ErrorMessage = "Stars must be from 1 to 5")]
        [Display(Name = "Maximum stars")]
        public int? StarsMax { get; set; }
        //address
        public string Country { get; set; }
        public string Region { get; set; }
        //store name of the selected city
        public string City { get; set; }
        [Display(Name = "City")]
        //store adddressid of the selected city
        public int? AddressId { get; set; }
        public string Street { get; set; }

        [Display(Name = "Reservation type")]
        public int? ReservationTypeId { get; set; }

        [Display(Name = "Hotel type")]
        public int? HotelTypeId { get; set; }

        // Additional filtration (second level)

        [Display(Name = "Room Type")]
        public int? RoomTypeId { get; set; }

        [Display(Name = "Facilities")]
        public int? FacilityId { get; set; }

        [Display(Name = "Hotel Rating")]
        public int? HotelId { get; set; }

        [Display(Name = "Room Minimum Price")]
        public int? RoomMinPrice { get; set; }

        [Display(Name = "Room Maximum Price")]
        public int? RoomMaxPrice { get; set; }
    }
}